package com.github;

import cn.hutool.extra.spring.SpringUtil;
import com.github.constant.MyConstant;
import com.github.manager.Manager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Component;
import org.springframework.web.client.RestTemplate;

public class DataFetcher {

    public static String getAccount(String token) {
        StringRedisTemplate stringRedisTemplate = SpringUtil.getBean(StringRedisTemplate.class);
        return (String) stringRedisTemplate.opsForHash().get(MyConstant.UserLoginToken,token);
    }

    public static void delTokenByAccount(String account) {
        StringRedisTemplate stringRedisTemplate = SpringUtil.getBean(StringRedisTemplate.class);
        stringRedisTemplate.opsForHash().get(MyConstant.UserLoginAccount,account);
    }

    public static void delAccountByToken(String token) {
        StringRedisTemplate stringRedisTemplate = SpringUtil.getBean(StringRedisTemplate.class);
        stringRedisTemplate.opsForHash().delete(MyConstant.UserLoginToken,token);
    }
}